/* Chymera is the Sakura Conductor */
/* This tab holds the Conductor specific (ie, Java on Windows)
 routines and procedures.  Platform specific code.  See Sakura project
 for the "sakura" tab, and it's Android specific code */

boolean androidMode = false;
boolean monitorMode=true;
boolean dontMove=false;

void setup() {
  size (384, 384, JAVA2D);
  if (frame != null) frame.setResizable(true);
  setupTone();
  commonSetup();
}
void positionWindow(int code, int i) {
  //480 per window cell -- set size
  
  switch (code) {
  case 0:
    frame.setSize(1280, 720); //the full sized target output
    dontMove=true;
    break;
  case 1: 
  case 2: 
  case 3: 
  case 4:
    int someValue=96;
    int reSize=someValue*code;
    frame.setSize(reSize, reSize);
    monitorMode=true;
    dontMove=false;
    break;
  default:
    break;
  }
  //! position based on bloom index  
  int xMod = i/8;
  println (xMod);
  int yMod = i/8+1;
  println (yMod);
  int margin = (480-width)/2;
  println(margin);
  if (!dontMove) {
    frame.setLocation(480*(i-xMod*8) + margin, margin*yMod + 480*xMod);
  }
}
void ChymeraStage() {
  if (makeToneTrigger) {
    SoundAct=true;
    out.addSignal(sine);
    makeTone=true;
    makeToneTrigger=false;
  } else {
    if (makeTone) {    
      delay(80);
      out.clearSignals();
      makeTone=false;
      SoundAct=false;
    }
  }
  if (monitorMode) {
    int cocked =0;
    String fTxt="";
    int tSize=(height/36+10);
    if (knownFacet!=16) { 
      fTxt = str(char(knownFacet+97));
    }
    stroke(0, 0, 0);
    strokeWeight(0);
    colorMode(RGB, 100);
    textSize(tSize);
    rectMode(RADIUS);
    strokeWeight(5);
    if (flowers[int(bloom[0])]==1) {
      fill (0, 70, 0);
      cocked++;
    } else {
      fill (70, 0, 0);
    }
    int someValue=width/18;
    rect(width-(someValue+10)*gr, (someValue+10)*gr, (someValue+10)*gr, (someValue+10)*gr);
    if (knownFacet <16) {
      if (FacetAct) {
        fill(0, 30, 70);
        cocked+=2;
      } else { 
        fill(0, 70, 0);
        cocked ++;
      }
    } else {
      fill(0);
    }
    rect((someValue+10)*gr, (someValue+10)*gr, (someValue+10)*gr, (someValue+10)*gr);
    fill(0);
    rectMode(CORNER);
    //! blackout 1/4 size of both left and right side for msgs
    rect(width-width/4, height-(someValue+5), width/4, (someValue+10));
    rect(0, height-(someValue+5), width/3, (someValue+10));
    noFill();
    if (cocked==2) {
      stroke(0, 100, 0);
      rect(0, 0, width, height);
    } else {
      if (cocked==3) {
        stroke(0, 30, 70);
        rect(0, 0, width, height);
      } else {      
        stroke(0, 0, 0);
        rect(0, 0, width, height);
      }
    }

    textAlign(RIGHT);
    //! Bloom assigned, Facet assigned, inputMsg, statMsg
    text(bloom[1], (width-tSize+10), tSize);
    textAlign(LEFT);
    text(fTxt, 10, tSize);
    textSize(tSize/=2);
    fill(100);
    text(inputMsg, 5, height-(someValue+10)*gr*gr);    
    textAlign(RIGHT);
    text(statMsg, width-5, height-(someValue+10)*gr*gr);
  }
  DisplayAct=false;
}

/* sakura (android) specific methods follow.
either write them for java, or leave blank if possible */

void ipFetch(){
  println("get IP, MAC, android only");
  IP="IP0";
  MAC="MAC0";
}
